package view.rules;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import net.miginfocom.swing.MigLayout;

public class MorphemPanel extends JPanel{
	
	public JRadioButton prefixRButton;
	public JRadioButton suffixRButton;
	public JRadioButton inPrefixRButton;
	public JRadioButton inSuffixRButton;
	private ButtonGroup buttonGroup;
	private JButton incluAffixButton;
	private JButton incluInfixButton;
	private JTextArea suffixArea;
	private JPanel panel;
	boolean prefix;
	boolean suffix;
	boolean inPrefix;
	boolean inSuffix;
	
	public MorphemPanel(){
		this.setLayout(new MigLayout());
		this.setBorder(BorderFactory.createTitledBorder("Morpheme Type"));
		initComponent();
		addComponent();
	}

	private void initComponent() {
		
		panel = new JPanel();
		panel.setLayout(new MigLayout());
		
		prefixRButton = new JRadioButton("Prefix");
		suffixRButton = new JRadioButton("Suffix");
		inPrefixRButton = new JRadioButton("Infix as Prefix");
		inSuffixRButton = new JRadioButton("Infix as Suffix");
		incluAffixButton = new JButton("Included Prefixies:");
		incluInfixButton = new JButton("Included Infixies");
		buttonGroup = new ButtonGroup();
		buttonGroup.add(prefixRButton);
		buttonGroup.add(suffixRButton);
		buttonGroup.add(inPrefixRButton);
		buttonGroup.add(inSuffixRButton);
		suffixArea = new JTextArea();
		suffixArea.setMinimumSize(new Dimension(250, 30));
		prefix = true;
		suffix = false;
		inPrefix = false;
		inSuffix = false;
		
	}

	private void addComponent() {
		
		panel.add(prefixRButton);
		panel.add(suffixRButton);
		panel.add(inPrefixRButton);
		panel.add(inSuffixRButton);
		panel.add(incluAffixButton);
		panel.add(suffixArea);
		
		add(panel);
	}
	
	
	public void setPanel(String affix){
		
		if (affix.equals("prefix") && prefix == false){
            incluAffixButton.setText("Included Prefixies:");
            prefix = true;
            suffix = false;
            inPrefix = false;
            inSuffix = false;
		}
		
		if (affix.equals("suffix") && suffix == false){
            
            incluAffixButton.setText("Included Suffixies:");
            suffix = true;
            prefix = false;
            inPrefix = false;
            inSuffix = false;
		}	
		
		if (affix.equals("infixPrefix") && inPrefix == false){
            
            incluAffixButton.setText("Included Indixes:");
            suffix = false;
            prefix = false;
            inPrefix = true;
            inSuffix = false;
		}

		if (affix.equals("infixSuffix") && inSuffix == false){
	    
		    incluAffixButton.setText("Included Indixes:");
		    suffix = false;
		    prefix = false;
		    inPrefix = false;
		    inSuffix = true;
		}
		
	}

}
